package com.woniuxy.carrental.controller;

import com.woniuxy.carrental.entity.City;
import com.woniuxy.carrental.entity.PageBean;
import com.woniuxy.carrental.entity.ResponseResult;
import com.woniuxy.carrental.service.CityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author author
 * @create 2021-10-10 13:21
 */
@RestController
public class CityController {

    @Autowired
    CityService cityService;


    @GetMapping("/getCity")
    public ResponseResult<PageBean<City>> getCity(){
        List<City> cities = cityService.selectAllCity();

        PageBean<City> pageBean=new PageBean();
        pageBean.setBeanList(cities);
        return new ResponseResult<PageBean<City>>(pageBean,200,"ok");
    }


    @GetMapping("/getCityByPid/{pid}")
    public ResponseResult<PageBean<City>> getCityByPid(@PathVariable("pid") int pid){
        List<City> cities = cityService.selectAllCityByPid(pid);
        PageBean<City> pageBean=new PageBean<>();
        pageBean.setBeanList(cities);
        return new ResponseResult<PageBean<City>>(pageBean,200,"ok");
    }


}
